import { Storage } from '../../utils/storage.js'

let {money, cardInfo, status} = Storage.get('bindCard', true) || {}
const state = {
  money: money || 100,
  cardInfo: cardInfo,
//status: status || 'ok'
  status: 'ok'
}

const actions = {

}

const getters = {
  money: state => state.money,
  cardInfo: state => state.cardInfo,
  status: state => state.status
}

const mutations = {
    bindCardState(state, {money, cardInfo, status}){
      Storage.set('bindCard', {money, cardInfo, status}, true)
      state.money = money
      state.cardInfo = cardInfo
      state.status = status
    }
}

export default {
    state,
    actions,
    getters,
    mutations
}
